<template>
  <div class="photoinfo-containter">
    <h2>{{photoinfo.title}}</h2>
    <p class="subtitle">
      <span>发表时间：{{photoinfo.add_time | dateFormat}}</span>
      <span>点击：{{photoinfo.click}}</span>
    </p>
    <hr>
    <vue-preview :slides="slide1"
                 class="suo"></vue-preview>
    <div class="content">{{photoinfo.content}}</div>
    <cmt-box :id="this.id"></cmt-box>
  </div>
</template>
<script>
import comment from '../subcomponents/comment.vue';
export default {
  data() {
    return {
      id: this.$route.params.id,
      photoinfo: {},
      slide1: []
    }
  },
  created() {
    this.getPhotoInfo();
    this.getThumbs();
  },
  methods: {
    getPhotoInfo() {
      this.axios.get('/getimageInfo?imgId=' + this.id).then(res => {
        this.photoinfo = res.data[0];
      })
    },
    getThumbs() {
      this.axios.get('/getthumimages/' + this.id).then(res => {
        res.data.img_url.forEach(el => {
          el.msrc = el.src;
          el.w = 600;
          el.h = 400;
        })
        this.slide1 = res.data.img_url
      })
    }
  },
  components: {
    'cmt-box': comment
  }
}
</script>
<style lang="scss">
.photoinfo-containter {
  padding: 3px;
  h2 {
    color: #26a2ff;
    font-size: 15px;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }
  .my-gallery {
    figure {
      display: inline-block;
      margin: 8px;
    }
    img {
      width: 100px;
      height: 100px;
      box-shadow: 0 0 8px #666;
    }
  }
  .content {
    font-size: 13px;
    line-height: 30px;
  }
}
</style>